package com.lagou.sqlSession;

import com.lagou.config.XMLConfigBuilder;
import com.lagou.io.Resources;
import com.lagou.pojo.Configuratioin;

import java.io.InputStream;

/**
 * @Description:
 * @Author: yw
 * @Date: 2021/7/23 22:50
 **/
public class SqlSessionFactoryBuilder {

    public SqlSessionFactory build(InputStream in) throws Exception {
        //使用dom4j解析配置文件，将内容封装到configuration中
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder();

        Configuratioin configuratioin = xmlConfigBuilder.parseConfig(in);

        //创建sqlSessionFactory对象
        DefaultSqlSessionFactory defaultSqlSessionFactory = new DefaultSqlSessionFactory(configuratioin);
        return defaultSqlSessionFactory ;
    }
}
